<!-- NOTE: Quirks mode document -->
<style>
  body {
    overflow: scroll;
    height: 500px;
    width: 500px;
  }
  #spacer {
    height: 10000px;
  }
</style>
<html>
    <body>
      <div id=spacer></div>
    </body>
</html>
<script src="../../../resources/js-test.js"></script>
<script>
    description('Verify that document.scrollingElement updates style in quirks mode without triggering layout');
    setPrintTestResultsLazily();

    document.body.offsetTop;
    shouldBe("internals.needsLayoutCount()", "0");

    document.body.style.padding = "10px";
    shouldBe("document.scrollingElement", "document.body");
    debug("Verifying layout hasn't been triggered");
    shouldBe("internals.needsLayoutCount()", "3");
    debug("But style update was");
    shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "0");

    document.documentElement.style.overflow = "scroll";

    // Workaround crbug.com/486034 to foce body style to be considered dirty
    document.body.style.padding = "8px";

    debug("Verify style change is reflected - body is now a real scrolling block element");
    shouldBeNull("document.scrollingElement");
    debug("Verifying layout still hasn't been triggered");
    shouldBe("internals.needsLayoutCount()", "3");
</script>
